package com.chelsea;

import java.awt.Color;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.JButton;
import javax.swing.JLabel;

public class Tag extends JLabel implements MouseListener{
	private String name;
	private int tagX;
	private int tagY;
	boolean toggle;
	Screen screen;
	
	public int getTagX() {
		return tagX;
	}

	public int getTagY() {
		return tagY;
	}

	public Tag(String s, int x, int y, Screen sc){
		super(s);
		
		this.name = s;
		this.tagX = x;
		this.tagY = y;
		this.addMouseListener(this);
		toggle = false;
		this.screen = sc;
	}
	
	public boolean checkRange(int currentX, int currentY, int tagSize){
		int offset = tagSize/2;
		int highX = this.tagX + offset;
		int highY = this.tagY + offset;
		int lowX = this.tagX - offset;
		int lowY = this.tagY - offset;
				
		boolean isInRangeX = currentX <= highX && currentX >= lowX;
		boolean isInRangeY = currentY <= highY && currentY >= lowY;
		
		if (isInRangeX && isInRangeY)
			return true;
		else
			return false;
	}

	@Override
	public void mouseClicked(MouseEvent e) {
		
		
	}

	public String getName() {
		return name;
	}

	public boolean isToggle() {
		return toggle;
	}

	public void setToggle(boolean toggle) {
		this.toggle = toggle;
	}

	@Override
	public void mouseEntered(MouseEvent e) {
		// TODO Auto-generated method stub
		this.setForeground(Color.BLUE);
		this.repaint();
		
			toggle = true;
	
			
		screen.viewTagByClick(this);
	}

	@Override
	public void mouseExited(MouseEvent e) {
		// TODO Auto-generated method stub
		this.setForeground(Color.BLACK);
		this.repaint();
		
		toggle = false;
		screen.viewTagByClick(this);
	}

	@Override
	public void mousePressed(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseReleased(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}
}
